package com.liull.netty.protobuf;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 21:09 2020/9/27
 * @Modified By:
 */
public class ProtoClientHandler extends SimpleChannelInboundHandler<DataInfo.Student> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DataInfo.Student msg) throws Exception {
        System.out.println("收到服务端消息" + msg);
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("链接服务端成功");
        DataInfo.Student student = DataInfo.Student.newBuilder().setName("李")
                .setAddress("南京")
                .setAge(15).build();
        ctx.writeAndFlush(student);
    }
}
